package com.pubgnode.factory;

import com.pubgnode.strategy.LoginStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;

/**
 * 登陆策略工厂类
 */
@Component
public class LoginStrategyFactory {


    @Autowired
    private Map<String, LoginStrategy> loginStrategyMap = new HashMap<>();


    /**
     * 工厂类的作用是用来构建具体策略的实例
     * 将每个登陆策略放进map集合
     * 根据用户登陆类型获取具体的登陆策略
     * @param loginType
     * @return
     */
    public LoginStrategy getInstance(String loginType){
        return loginStrategyMap.get(loginType);
    }
}
